<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;
use Jedrzej\Pimpable\PimpableTrait;

class Permission extends Model
{
    use HasFactory;
    use PimpableTrait;
    use SoftDeletes;

    /**
     * 可批量赋值字段
     */
    public $fillable = [
        'name',
        'cn_name',
        'guard_name',
        'status',
        'level',
        'pid',
        'system_admin_id',
        'path',
        'parameter',
        'interfacepath',
        'mode',
        'is_hidden',
    ];


    /**
     * 类型枚举
     */
    public  $FrontType = [
        'adminTaype' => '接口',
        'authTaype' => '菜单',
    ];



    /**
     * 可搜索的字段
     */

    public $searchable = [
        'name',
        'cn_name',
        'created_at',
    ];

    /**
     * 可排序字段
     */
    public $sortable = [
        'id',
    ];
    /**
     * 默认排序字段
     */
    protected $defaultSortCriteria = ['id,desc'];


    public function children(){
        return $this->hasMany(Permission::class,'pid','id');
    }
}

